#include "buffer.h"
#include "string.h"
Buffer::Buffer()
{
	Init();
}

Buffer::~Buffer()
{
}

void Buffer::Init()
{
	m_Used = 0;
	SetBodySize(-1);
}

void Buffer::SetBodySize(s32int Size)
{
	*((s32int *)m_Buf) = Size;
}

s32int Buffer::GetBodySize()
{
	s32int * pSize;
	pSize = (s32int *)m_Buf;
	return *pSize;
}

void Buffer::Append(void * Value, u32int Size)
{
	memcpy(m_Buf + m_Used, Value, Size);
	m_Used += Size;
	SetBodySize(m_Used - S32INT_SIZE);
}

void * Buffer::GetBody()
{
	return (void *)(m_Buf + S32INT_SIZE);
}

u32int Buffer::GetUsed()
{
	return m_Used;
}
